/**
* Created by jhf on 14-10-13.
*/
//客户端
var WebSocket = require('ws')
    ,Options = require('options');

var options = new Options({"headers":{}});
options = {
    "headers":{"userid":"abc"}
};
var ws = new WebSocket('ws://127.0.0.1:8080',options);

ws.on('open',function(ss){
    var obj = {
        "toUserIconUrl": "/api/getPicture/53c9e22cce37989659b24852",
        "toUserName": "Fred",
        "toUserId": "54237cb58c29a38f44362082",
        "content": "测试消息",
        "fromUserIconUrl": "/api/getPicture/53c0b7337a4dd8f77549838e",
        "fromUserName": "Jin",
        "fromUserId": "538aacd78016832f19000062",
        "contentType": "text",
        "time": (new Date()).getTime()
    };
    var str = JSON.stringify(obj);
    console.log(str);
    ws.send(str);

});
ws.on('message',function(message){
   console.log('received: %s',message);
});